/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.employee.service;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.chlitina.store.common.persistence.Page;
import com.chlitina.store.common.service.BaseService;
import com.chlitina.store.modules.employee.dao.StoreEmployeeAccountingDetailDao;
import com.chlitina.store.modules.employee.entity.StoreEmployeeAccountingDetail;

/**
 * 员工结算单明细Service
 * @author liujiang
 * @version 2013-11-21
 */
@Component
@Transactional(readOnly = true)
public class StoreEmployeeAccountingDetailService extends BaseService {

	@SuppressWarnings("unused")
	private static Logger logger = LoggerFactory.getLogger(StoreEmployeeAccountingDetailService.class);
	
	@Autowired
	private StoreEmployeeAccountingDetailDao storeEmployeeAccountingDetailDao;
	
	public StoreEmployeeAccountingDetail get(Long id) {
		return storeEmployeeAccountingDetailDao.findOne(id);
	}
	
	public Page<StoreEmployeeAccountingDetail> find(Page<StoreEmployeeAccountingDetail> page, Long account_id) {
		DetachedCriteria dc = storeEmployeeAccountingDetailDao.createDetachedCriteria();
		dc.add(Restrictions.eq("storeEmployeeAccounting.id", account_id));
		dc.addOrder(Order.asc("id"));
		return storeEmployeeAccountingDetailDao.find(page, dc);
	}
	
	@Transactional(readOnly = false)
	public void save(StoreEmployeeAccountingDetail storeEmployeeAccountingDetail) {
		storeEmployeeAccountingDetailDao.save(storeEmployeeAccountingDetail);
	}
	
	@Transactional(readOnly = false)
	public void delete(Long id) {
		storeEmployeeAccountingDetailDao.delete(id);
	}
	
}
